package com.naiking.ui
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class FButton extends Sprite
	{
		private var _lbl:TextField;
		private var _lblStr:String;
		public function FButton()
		{
			super();
			_lbl=new TextField();
			_lbl.autoSize="left";
			addChild(_lbl);
			this.mouseChildren=false;
			this.addEventListener(MouseEvent.ROLL_OVER,onOver);
			this.addEventListener(MouseEvent.ROLL_OUT,onOut);
			
		}
		
		protected function onOut(event:MouseEvent):void
		{
			this.graphics.clear();
			this.graphics.beginFill(0xffcc33);
			this.graphics.drawRect(0,0,_lbl.width+10,_lbl.height+10);
			this.graphics.endFill();
		}
		
		protected function onOver(event:MouseEvent):void
		{
			this.graphics.clear();
			this.graphics.beginFill(0xffde79);
			this.graphics.drawRect(0,0,_lbl.width+10,_lbl.height+10);
			this.graphics.endFill();
		}
		private function resize():void
		{
			this.graphics.clear();
			this.graphics.beginFill(0xffcc33);
			this.graphics.drawRect(0,0,_lbl.width+10,_lbl.height+10);
			this.graphics.endFill();
			_lbl.x=5;
			_lbl.y=5;
		}
		public function set lable(value:String):void
		{
			_lblStr=value;
			_lbl.text=_lblStr;
			resize();
		}
	}
}